#include <stdio.h>  
#include <stdlib.h>  
#include <pthread.h>  
  
// 定义一个结构体来存储传递给线程的参数  
typedef struct {  
    const char *str;  
    int int_val;  
    int *int_array;  
    size_t array_len;  
} ThreadArgs;  
  
void *fun(void *arg) {  
    ThreadArgs *args = (ThreadArgs *)arg;  
    printf("%s %d ", args->str, args->int_val);  
    for (size_t i = 0; i < args->array_len; i++) {  
        printf("%d ", args->int_array[i]);  
    }  
    printf("\n");  
    return NULL;  
}  
  
int main(int argc, char *argv[]) {  
    pthread_t thread;  
    int a = 100;  
    int b[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};  
    size_t len = sizeof(b) / sizeof(int);  
  
    // 分配并初始化结构体  
    ThreadArgs args = {  
        .str = "Hello",  
        .int_val = a,  
        .int_array = b,  
        .array_len = len  
    };  
  
    // 创建线程，传递结构体的地址  
    pthread_create(&thread, NULL, fun, &args);  
  
    // 等待线程完成  
    pthread_join(thread, NULL);  
  
    return 0;  
}